<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <title>项目刚性指标</title>
  <style type="text/css">
  </style>
</head>
<body>
  <div class="layui-fluid">   
    <div class="layui-card">
      <!-- 查询区域  -->
      <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            	<label class="layui-form-label">统计期间</label>
            	<div class="layui-input-inline">
              		<input type="text" class="layui-input" id="sts_month_start"  name="stsMonthStart" readonly placeholder="开始月份">
            	</div>
            	<div class="layui-form-mid">
               	-
            	</div>
            	<div class="layui-input-inline">
              		<input type="text" class="layui-input" id="sts_month_end" name="stsMonthEnd" readonly placeholder="结束月份">
            	</div>
          </div>
          <div class="layui-inline">
            	<label class="layui-form-label">公司主体</label>
            	<div class="layui-input-inline" style="width:260px;">
              		<select name="orgTypeAndId" id="query_select_orgId" lay-filter="query_select_orgId" lay-search >
	              		<c:if test="${not empty orgInfos }">
	              			<c:forEach items="${orgInfos}" var="org">
	              				<option value="${org.id}-${org.types}" <c:if test="${org.id == bindOrgId }">selected</c:if>>${org.compName }</option>
		            		</c:forEach>
	              		</c:if>
	              	</select>
            	</div>
          	</div>
          	<div class="layui-inline">
            	<label class="layui-form-label">项目名称</label>
            	<div class="layui-input-inline">
              		<input type="text" name="orgProName" id="query_input_orgProName"  placeholder="请输入" autocomplete="off" class="layui-input" >
            	</div>
          	</div>
          	<shiro:hasPermission name="LIST_ORG_PRO_QA">
	          <div class="layui-inline">
	            <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-orgProQa-search">
	              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
	            </button>
	          </div>
          	</shiro:hasPermission>
        </div>
      </div>
      <div class="layui-card-body">
      <div style="text-align: center; margin-top:5px;  margin-bottom:18px;">
	          <div class="layui-inline" style="float:right;margin-bottom:2px;margin-right:0px;">
		         	<label class="layui-form-label">单位</label> 
	         	 	<div class="layui-inline layui-form" style="width:70px;">
		         	<select id="money_unit_ctrl" class="layui-select" lay-filter="money_unit_ctrl" >
			    	<option value='1'>元</option>
					<option value="2" selected>万元</option>
					<option value="3">亿元</option>
				  </select>
				  </div>
          	  </div>
        </div>
        <hr/>
        <table id="LAY-orgProQa-manage" lay-filter="LAY-orgProQa-manage"></table>
      </div>
    </div>
  </div>

  <script>
  var stageJSON = <infopub:dicJson groupNo="A00010077" />;
  	layui.config({
    	base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index' //主入口模块
  	}).use(['index', 'table', 'set', 'laydate', 'element'], function(){
    	var $ = layui.$
    	,form = layui.form
    	,table = layui.table
    	,laydate = layui.laydate
    	,element = layui.element;
    	
    	var insStart = laydate.render({
	      elem: '#sts_month_start'
	      ,type: 'month'
	      ,btns: ['now', 'confirm']
	      ,format:'yyyy年MM月'
	      ,value: layui.util.toDateString(new Date().getTime() - 2592000000 , 'yyyy年MM月') //30天前
	      ,done:function(value, date){
	    	  //更新结束日期的最小日期
  	          insEnd.config.min = lay.extend({}, date, {
  	              month: date.month - 1
  	          });
	  	        
  	          //自动弹出结束日期的选择器
	  	      insEnd.config.elem[0].focus();
  	          
	      	  table.reload('LAY-orgProQa-manage', {page: {curr: 1},
			 	 where: {'stsMonthStart':value,'stsMonthEnd':$("#sts_month_end").val(),'orgTypeAndId':$('#query_select_orgId').val(),'orgProName':$('#query_input_orgProName').val()}
		      });
	      }
	    });
	    
    	var insEnd = laydate.render({
	      elem: '#sts_month_end'
	      ,type: 'month'
	      ,btns: ['now', 'confirm']
	      ,format:'yyyy年MM月'
	      ,value: layui.util.toDateString(new Date().getTime() - 2592000000 , 'yyyy年MM月') //30天前
	      ,done:function(value, date){
	    	  //更新开始日期的最大日期
        	  insStart.config.max = lay.extend({}, date, {
	  	          month: date.month - 1
	  	      });
	    	  
	      	  table.reload('LAY-orgProQa-manage', {page: {curr: 1},
			 	 where: {'stsMonthStart':$("#sts_month_start").val(),'stsMonthEnd':value,'orgTypeAndId':$('#query_select_orgId').val(),'orgProName':$('#query_input_orgProName').val()}
		      });
	      }
	    });
    	
    	var colsInit = [
    					{type:'numbers', title: '序号',fixed:'left', width: 80, align:'center'}
    					,{field: 'orgAreaName', title: '区域公司',fixed:'left',width: 180, align:'center'}
    					,{field: 'proName', title: '项目名称',fixed:'left',width: 300, align:'center'}					
    					,{field: 'curMonthFinish2', title: '融资额(元)',hide:true, align:'center', templet: function(d){
    							return formatCurrency(d.curMonthFinish2);						    					
    						}
    					}
    					,{field: 'curMonthFinishTts2', title: '融资额(万元)',align:'center', templet: function(d){
								return formatCurrency(d.curMonthFinishTts2);					    					
							}
						}
    					,{field: 'curMonthFinishHms2', title: '融资额(亿元)',hide:true,align:'center', templet: function(d){
	    						if(d.curMonthFinishHms2 == null){
									return 0;
								}else{
									return d.curMonthFinishHms2;
								}					    					
							}
						}
    					,{field: 'curMonthFinish3', title: '投资额(元)',hide:true, align:'center', templet: function(d){
    							return formatCurrency(d.curMonthFinish3);	
    						}
    					}
    					,{field: 'curMonthFinishTts3', title: '投资额(万元)', align:'center', templet: function(d){
								return formatCurrency(d.curMonthFinishTts3);	
							}
						}
    					,{field: 'curMonthFinishHms3', title: '投资额(亿元)',hide:true,align:'center', templet: function(d){
								if(d.curMonthFinishHms3 == null){
									return 0;
								}else{
									return d.curMonthFinishHms3;
								}
							}
						}
    					,{field: 'curMonthFinish4', title: '管理净利润(元)',hide:true,align:'center', templet: function(d){
    							return formatCurrency(d.curMonthFinish4);	
    						}
    					}
    					,{field: 'curMonthFinishTts4', title: '管理净利润(万元)', align:'center', templet: function(d){
								return formatCurrency(d.curMonthFinishTts4);	
							}
						}
    					,{field: 'curMonthFinishHms4', title: '管理净利润(亿元)',hide:true,align:'center', templet: function(d){
								if(d.curMonthFinishHms4 == null){
									return 0;
								}else{
									return d.curMonthFinishHms4;
								}	
							}
						}
    				  ];
    	
    	/* 渲染判断 */
    	function customerCols(){
   			var unit = $('#money_unit_ctrl').val();
   			if(unit==1){
   				// 元
   				colsInit[3].hide = false;
				colsInit[6].hide = false;
				colsInit[9].hide = false;
   				// 万元
   				colsInit[4].hide = true;
				colsInit[7].hide = true;
				colsInit[10].hide = true;
   				// 亿元
				colsInit[5].hide = true;
				colsInit[8].hide = true;
				colsInit[11].hide = true;
   			}
   			if(unit==2){
   				// 元
   				colsInit[3].hide = true;
				colsInit[6].hide = true;
				colsInit[9].hide = true;
   				// 万元
   				colsInit[4].hide = false;
				colsInit[7].hide = false;
				colsInit[10].hide = false;
   				// 亿元
				colsInit[5].hide = true;
				colsInit[8].hide = true;
				colsInit[11].hide = true;
   			}
   			if(unit==3){
   				// 元
   				colsInit[3].hide = true;
				colsInit[6].hide = true;
				colsInit[9].hide = true;
   				// 万元
   				colsInit[4].hide = true;
				colsInit[7].hide = true;
				colsInit[10].hide = true;
   				// 亿元
				colsInit[5].hide = false;
				colsInit[8].hide = false;
				colsInit[11].hide = false;
   			}
   		}
    	
    	var stsMonthStart = $('#sts_month_start').val();
		var stsMonthEnd = $('#sts_month_end').val();
    	// 切换单位时 重新渲染		
		form.on('select(money_unit_ctrl)', function(data){
			// 处理列显示
			customerCols();
			// 表单
	    	table.render({
	      		elem: '#LAY-orgProQa-manage'
	      		,url: basePath + '/orgProQa/queryDataByCondition' //请求数据接口
	      		,cols: [colsInit]
	      		,page: true
	      		,limit: 10
	      		,where: {'stsMonthStart':$('#sts_month_start').val(),'stsMonthEnd':$('#sts_month_end').val(),'orgTypeAndId':$('#query_select_orgId').val(),'orgProName':$('#query_input_orgProName').val()}
	    	});
    	});
	    
		form.on('select(query_select_orgId)', function(data){
   		 	table.reload('LAY-orgProQa-manage', {page: {curr: 1},
		 		where: {'stsMonthStart':$('#sts_month_start').val(),'stsMonthEnd':$('#sts_month_end').val(),'orgTypeAndId':$('#query_select_orgId').val(),'orgProName':$('#query_input_orgProName').val()}
	      	});
    	});
		
    	// 表单
    	table.render({
      		elem: '#LAY-orgProQa-manage'
      		,url: basePath + '/orgProQa/queryDataByCondition' //请求数据接口
      		,where: {'stsMonthStart':stsMonthStart,'stsMonthEnd':stsMonthEnd,'orgTypeAndId':$('#query_select_orgId').val(),'orgProName':$('#query_input_orgProName').val()}
      		,cols: [colsInit]
      		,page: true
      		,limit: 10
    	});

    	<shiro:hasPermission name="LIST_ORG_PRO_QA">
	    	//监听搜索
	    	form.on('submit(LAY-orgProQa-search)', function(data){
		      	//执行重载
		      	table.reload('LAY-orgProQa-manage', {page: {curr: 1},
		        	where: trimData(data)
		      	});
	    	});
    	</shiro:hasPermission>
  });
  	
  </script>
</body>
</html>

